package cn.exrick.xboot.modules.workovertime.controller;


import cn.exrick.xboot.common.utils.ResultUtil;
import cn.exrick.xboot.common.vo.Result;
import cn.exrick.xboot.config.custom.CustomPageUtils;
import cn.exrick.xboot.modules.workovertime.VO.HkOvertimeDetailVo;
import cn.exrick.xboot.modules.workovertime.VO.HkassessmentOvertimeAndRecordVo;
import cn.exrick.xboot.modules.workovertime.entity.HkOvertimeDetail;
import cn.exrick.xboot.modules.workovertime.service.IHkOvertimeDetailService;
import cn.exrick.xboot.modules.workovertime.service.IHkOvertimeInfoService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;
import com.alibaba.fastjson.JSON;
import org.springframework.ui.Model;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.*;
import java.util.concurrent.TimeUnit;

/**
 * @author hml
 * @since 2023-08-31
 */
@RestController
@RequestMapping("/performance/hkOvertimeDetail")
public class HkOvertimeDetailController {
    private final Logger logger = LoggerFactory.getLogger(HkOvertimeDetailController.class);

    @Autowired
    public IHkOvertimeDetailService iHkOvertimeDetailService;
    @Autowired
    public RedisTemplate redisTemplate;
    @Autowired
    private IHkOvertimeInfoService iHkOvertimeInfoService;

    /**
     * 分页查询数据
     *
     * @param page             分页信息
     * @param hkOvertimeDetail 查询条件
     * @return
     */
    @ResponseBody
    @GetMapping("/getHkOvertimeDetailPageList")
    public Result<Object> getHkOvertimeDetailPageList(Page<HkOvertimeDetail> page, HkOvertimeDetail hkOvertimeDetail) {
        return ResultUtil.data(CustomPageUtils.getCustomPage(iHkOvertimeDetailService.selectPage(page, hkOvertimeDetail)));
    }

    /**
     * processInstanceId
     *
     * @param processInstanceId 实体ID
     * @return 0 失败  1 成功
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.GET, value = "/getHkOvertimeDetial")
    public Result<Object> getHkOvertimeDetial(String processInstanceId) {
        HkassessmentOvertimeAndRecordVo byPrcessId = iHkOvertimeDetailService.getHkOvertimeDetial(processInstanceId);
        return ResultUtil.data(byPrcessId);
    }

    /**
     * 根据id获取对象
     *
     * @param id 实体ID
     * @return 0 失败  1 成功
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.GET, value = "/hkOvertimeDetailGetById")
    public Result<Object> hkOvertimeDetailGetById(String id) {
        HkOvertimeDetail byId = iHkOvertimeDetailService.getById(id);
        return ResultUtil.data(byId);
    }

    /**
     * 根据id删除对象
     *
     * @param id 实体ID
     * @return 0 失败  1 成功
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "/hkOvertimeDetailDelete")
    public Result<Object> hontUserDelete(String id) {
        iHkOvertimeDetailService.removeById(id);
        return ResultUtil.success("删除成功");
    }

    /**
     * 批量删除对象
     *
     * @param item 实体集合ID
     * @return 0 失败  1 成功
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "/hkOvertimeDetailBatchDelete")
    public Result<Object> deleteBatchIds(String item) {
        List<String> ids = (List<String>) JSON.parse(item);
        iHkOvertimeDetailService.removeByIds(ids);
        return ResultUtil.success("删除成功");
    }

}
